using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Petra.Gis.Geometry;
using Petra.Gis.Geometry.Support;
using Petra.Gis.DataServices.WKT.Support;

namespace Petra.Gis.DataServices.WKT
{
  public partial class GeometryFactory
  {
    /***********************************************
     * 28.8.2007
     * 
     * creates LineRing
     * from wkb blob
     * 
     * asida@centrum.cz, initial implementation
     *************************************************/

    private static LineRing ToLineRing(RegexGeometry rg, WKTGeometryType parentGeomType)
    {

      CoordinateList Coords = CoordinateListConverter.ToCoordinateList(rg, Dimension.dim2D);
      LineRing oGeom = new LineRing();
      oGeom.coordList = Coords;

      return oGeom;
    
    }

    /*
    private static LineRing ToLineRing(CaptureCollection cc, Capture aproxStart, Capture aproxEnd, System.Type parentGeomType)
    {

      int _start, _end;
      //get num of coords
      //get begin coord index
      for (_start = 0; _start < cc.Count; _start++)
        if (aproxStart.Index < cc[_start].Index)
          break;

      //get end coord index
      for (_end = _start; _end < cc.Count; _end++)
        if (aproxEnd.Index < cc[_end].Index)
        {
          _end--;
          break;
        }

      LineRing _geom = new LineRing();
      CoordinateList Coords = CoordinateListConverter.ToCoordinateList(cc, _start, _end, Dimension.dim2D);
      _geom.coordList = Coords;
      return _geom;

    }
    */


    /***********************************************
     * 28.8.2007
     * 
     * creates string 
     * from LineRing
     * 
     * asida@centrum.cz, initial implementation
     *************************************************/
    internal static string LineRingToString(LineRing geom, WKTGeometryType parentGeometryType)
    {

      System.IO.StringWriter mStrWriter = new System.IO.StringWriter();

      mStrWriter.Write("(");
      mStrWriter.Write(CoordinateListConverter.ToString(geom.coordList, Dimension.dim2D));
      mStrWriter.Write(")");

      return mStrWriter.ToString();
    }

  }
}
